/*********************************************************
          File Name:10.25.cpp
          Author: Abby Cin
          Mail: abbytsing@gmail.com
          Created Time: Mon 14 Mar 2016 06:52:59 PM CST
**********************************************************/

#include <iostream>
#include <functional>
#include <string>
#include <vector>
#include <algorithm>

using namespace std;
using namespace std::placeholders;

bool check_size(const string &s, size_t sz)
{
    return s.size() >= sz;
}

void out(const string &s)
{
    cout << s << " ";
}

void bigges(vector<string> &words, vector<string>::size_type sz)
{
    sort(words.begin(), words.end());
    words.erase(unique(words.begin(), words.end()), words.end());
    stable_sort(words.begin(), words.end());

    auto wc = partition(words.begin(), words.end(), bind(check_size, _1, sz));

    cout << wc - words.begin() << " word(s) of length " << sz << " or longer\n";

    for_each(words.begin(), wc, bind(out, _1));

    cout << endl;
}

int main()
{
    vector<string> vs{"the", "blue", "firefox", "jump", "over", "blue", "dog"};
    bigges(vs, 4);
    return 0;
}
